﻿<!DOCTYPE html>
<head>
<title>Xrm JavaScript Dojo Editor</title>
<style type="text/css" media="screen">
    #editor { 
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
</style>
<meta charset="utf-8">
</head>
<body>
<div id="editor"></div>
<script type="text/javascript" charset="utf-8" src="ace.js"></script>
<script type="text/javascript">
    function setEditorValue(value) {
        if (editor === undefined) {
            alert("Editor not found!");
        }
        else {
            editor.setValue(value, 0);
        }
    }
    function getEditorValue() {
        if (editor === undefined) {
            alert("Editor not found!");
        }
        else {
            return editor.getValue();
        }
    }
</script>
<script type="text/javascript">
    var editor = ace.edit("editor");
    editor.getSession().setMode("ace/mode/javascript");
    var sourcecode = window.parent.Xrm.Page.getAttribute("dojo_sourcecode").getValue();
    if (sourcecode == null) { sourcecode = ""; }
    setEditorValue(sourcecode);
    editor.clearSelection();
</script>
</body>
</html>